<div class="row">
    <div clsss="col-xs-12">
        <div class="clearfix" style="text-align: right; padding-right: 12px;">
            <div class="btn-group" role="group" aria-label="First group">
                <a href="/admin/peoples/create?action=<?php echo \Input::get('action', 'peoples-add'); ?>" class="btn btn-default"><i class="fa fa-plus"></i></a>
            </div>
        </div>
    </div>
</div>
<div class="row" style="margin-top: 10px;">
    <div class="col-xs-12">
        <?php if(isset($items) && $items){ ?>
        <table id="simple-table" class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th class="center">
                        <label class="pos-rel">
                            <input type="checkbox" class="ace">
                            <span class="lbl"></span>
                        </label>
                    </th>
                    <th>ID</th>
                    <th>照片</th>
                    <th>出生日期</th>
                    <th>手机号码</th>
                    <th>身份证号码</th>
                    <!--<th>户籍地址</th>-->
                    <th>居住地址</th>
                    <th>邮箱地址</th>
                    <!--<th>个人介绍</th>
                    <th>创建日期</th>-->
                    <th>修改日期</th>
                    <th>操作</th>
                </tr>
            </thead>

            <tbody>
                <?php foreach ($items as $key => $value) { ?>
                <tr data-id="<?php echo $value->id; ?>">
                    <td class="center">
                        <label class="pos-rel">
                            <input type="checkbox" class="ace">
                            <span class="lbl"></span>
                        </label>
                    </td>

                    <td><?php echo $value->id; ?></td>
                    <td>
                        <?php if(isset($value->photoalbum) && count($value->photoalbum)>0){ ?>
                        <div style="position: relative;height: 100px;">
                          <div style="display: block;margin: 0 auto;max-width: 74px;max-height: 107px;">
                            <a style="display: inline-block;border: 3px solid #fff;background-clip: padding-box;max-width: 100px;max-height: 100px;overflow: hidden;">
                              <img src="<?php echo current($value->photoalbum)->src;?>" alt="" style="width:80px;height: 80px;"></a>
                          </div>
                          <p style="height: 17px;line-height: 17px;text-align: center;font-weight: 700;">
                            <i style="background: url(<?php echo $value->gender && stristr($value->gender,'男') !=""? '/assets/img/male.png': '/assets/img/female.png';?>) 0 0 no-repeat;display: inline-block;position: relative;height: 16px;width: 16px;"></i><?php echo $value->last_name ? $value->last_name : ''; ?></p>
                        </div>
                        <?php } ?>
                    </td>                    
                    <td><?php echo $value->birthday ? $value->birthday : ''; ?></td>
                    <td><?php echo $value->phone ? $value->phone :''; ?></td>
                    <td><?php echo $value->identity ? $value->identity :''; ?></td>
                    <!--<td><?php //echo $value->residence_address ? $value->residence_address:''; ?></td>-->
                    <td><?php echo $value->address ? $value->address:''; ?></td>                    
                    <td><?php echo $value->email ? $value->email : ''; ?></td>
                    <!--<td><?php //echo $value->introduction ? $value->introduction:''; ?></td>-->
                    <!--<td><?php //echo $value->created_at ? date('Y-m-d H:i:s', $value->created_at) : '-'; ?></td>-->
                    <td><?php echo $value->updated_at ? date('Y-m-d H:i:s', $value->updated_at) : '-'; ?></td>
                    <td>
                        <div class="hidden-sm hidden-xs btn-group">
                            <a href="/admin/peoples/create/<?php echo $value->id; ?>?action=<?php echo \Input::get('action', 'peoples-add'); ?>" class="btn btn-xs btn-info" title="编辑">
                                <i class="ace-icon fa fa-pencil bigger-120"></i>
                            </a>

                            <a class="btn btn-xs btn-danger" title="删除" data-toggle="modal" data-target="#confirmModal">
                                <i class="ace-icon fa fa-trash-o bigger-120"></i>
                            </a>
                        </div>

                        <div class="hidden-md hidden-lg">
                            <div class="inline pos-rel">
                                <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                    <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                </button>

                                <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                    <li>
                                        <a href="#" class="tooltip-info" data-rel="tooltip" title="" data-original-title="View">
                                            <span class="blue">
                                                <i class="ace-icon fa fa-qrcode bigger-120"></i>
                                            </span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#" class="tooltip-success" data-rel="tooltip" title="" data-original-title="Edit">
                                            <span class="green">
                                                <i class="ace-icon fa fa-bar-chart bigger-120"></i>
                                            </span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#" class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
                                            <span class="red">
                                                <i class="ace-icon fa fa-pencil bigger-120"></i>
                                            </span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#" class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
                                            <span class="red">
                                                <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                            </span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </td>
                </tr>
                <?php } ?>
            </tbody>
            <?php if(isset($pagination) && $pagination){ ?>
            <tfoot>
                <tr>
                    <td colspan="9" style="text-align: right;">
                        <?php echo isset($pagination) && $pagination ? htmlspecialchars_decode($pagination) : ''; ?>
                    </td>
                </tr>
            </tfoot>
            <?php } ?>
        </table>
        <?php }else{ ?>
        <div style="border: 1px solid #e0e0e0; line-height: 300px; width: 100%; text-align: center;">
            未找到相关数据
        </div>
        <?php } ?>
    </div><!-- /.span -->
</div>
<?php echo render('ace/public/alert_message'); ?>
<?php echo render('ace/public/confirm_modal'); ?>
<script type="text/javascript">
//触发删除对象的a标签
var a;
//确认删除后的回调方法
function confirmDelete(result) {
    if(result) {
        var i = $(a).find('i');
        var self = $(a).parents('tr');

        $(a).addClass('disabled');
        $(i).addClass('fa-spinner').addClass('fa-spin').removeClass('fa-trash-o');

        $.get('/admin/peoples/delete/' + self.attr('data-id'), 
            function(data, status){
                $(a).removeClass('disabled');
                $(i).removeClass('fa-spinner').removeClass('fa-spin').addClass('fa-trash-o');
                if(data.status == 'err'){
                    showResultMessage('删除失败', '', 'danger');
                    return;
                }
                showResultMessage('删除成功', '', 'success');
                self.remove();
            }, 'json');
    }
}
</script>